using Afterlife.Screens;
using AfterlifeLib.GameScreens;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Afterlife
{
    public class AfterlifeGame : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        ScreenManager screenManager;

        public AfterlifeGame()
        {
            Content.RootDirectory = "Content";

            SetupGraphicsDevice();

            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            screenManager.AddScreen(new BackgroundScreen("Images/UI/background"));
            screenManager.AddScreen(new MainMenuScreen());

#if DEBUG
            this.IsMouseVisible = true;
            Components.Add(new AfterlifeLib.Components.FPSComponent(this));
#else
            this.IsMouseVisible = true;
#endif
            this.IsFixedTimeStep = false;
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            base.Draw(gameTime);
        }

        void SetupGraphicsDevice()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;

#if DEBUG
            graphics.SynchronizeWithVerticalRetrace = false;
#else
            graphics.SynchronizeWithVerticalRetrace = true;
#endif
        }
    }

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            using (AfterlifeGame game = new AfterlifeGame())
            {
                game.Run();
            }
        }

        //static void Main(string[] args)
        //{
        //    ParticleSettings particleSettings = new ParticleSettings();

        //    XmlWriterSettings settings = new XmlWriterSettings();
        //    settings.Indent = true;

        //    using (XmlWriter writer = XmlWriter.Create("particleSettings.xml", settings))
        //    {
        //        IntermediateSerializer.Serialize(writer, particleSettings, null);
        //    }
        //}
    }
}
